package com.ruoyi.ade.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ade.domain.AdePrompt;
import com.ruoyi.ade.service.IAdePromptService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * Prompt ExploreController
 * 
 * @author wxh
 * @date 2025-06-18
 */
@RestController
@RequestMapping("/ade/prompt")
public class AdePromptController extends BaseController
{
    @Autowired
    private IAdePromptService adePromptService;

    /**
     * 查询Prompt Explore列表
     */
    @PreAuthorize("@ss.hasPermi('ade:prompt:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdePrompt adePrompt)
    {
        startPage();
        List<AdePrompt> list = adePromptService.selectAdePromptList(adePrompt);
        return getDataTable(list);
    }

    @GetMapping("/listAll")
    public AjaxResult all(AdePrompt adePrompt){
        List<AdePrompt> list = adePromptService.selectAdePromptList(adePrompt);
        return success(list);
    }


    /**
     * 导出Prompt Explore列表
     */
    @PreAuthorize("@ss.hasPermi('ade:prompt:export')")
    @Log(title = "Prompt Explore", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdePrompt adePrompt)
    {
        List<AdePrompt> list = adePromptService.selectAdePromptList(adePrompt);
        ExcelUtil<AdePrompt> util = new ExcelUtil<AdePrompt>(AdePrompt.class);
        util.exportExcel(response, list, "Prompt Explore数据");
    }

    /**
     * 获取Prompt Explore详细信息
     */
    @PreAuthorize("@ss.hasPermi('ade:prompt:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(adePromptService.selectAdePromptById(id));
    }

    /**
     * 新增Prompt Explore
     */
    @PreAuthorize("@ss.hasPermi('ade:prompt:add')")
    @Log(title = "Prompt Explore", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdePrompt adePrompt)
    {
        adePrompt.setCreateBy(getUsername());
        return toAjax(adePromptService.insertAdePrompt(adePrompt));
    }

    /**
     * 修改Prompt Explore
     */
    @PreAuthorize("@ss.hasPermi('ade:prompt:edit')")
    @Log(title = "Prompt Explore", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdePrompt adePrompt)
    {
        adePrompt.setUpdateBy(getUsername());
        return toAjax(adePromptService.updateAdePrompt(adePrompt));
    }

    /**
     * 删除Prompt Explore
     */
    @PreAuthorize("@ss.hasPermi('ade:prompt:remove')")
    @Log(title = "Prompt Explore", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(adePromptService.deleteAdePromptByIds(ids));
    }
}
